package com.itcs4155.haveyourbac;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.WindowManager;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.data.filter.Approximator;
import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
import com.github.mikephil.charting.utils.XLabels;
import com.github.mikephil.charting.utils.YLabels;
import java.util.ArrayList;
public class CloseTabScreen extends FragmentActivity implements OnSeekBarChangeListener {
private LineChart mChart;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_close_tab_screen);
mChart = (LineChart) findViewById(R.id.ourChart);
// if enabled, the chart will always start at zero on the y-axis
mChart.setStartAtZero(true);
// disable the drawing of values into the chart
mChart.setDrawYValues(false);
mChart.setDrawBorder(false);
mChart.setDrawLegend(false);
// no description text
mChart.setDescription("");
mChart.setUnit(" ");
// enable value highlighting
mChart.setHighlightEnabled(true);
// enable touch gestures
mChart.setTouchEnabled(true);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
mChart.setDrawVerticalGrid(false);
Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
mChart.setValueTypeface(tf);
XLabels x = mChart.getXLabels();
x.setTypeface(tf);
YLabels y = mChart.getYLabels();
y.setTypeface(tf);
y.setLabelCount(5);
// add data
setData(12, 10);
mChart.animateXY(2000, 2000);
// dont forget to refresh the drawing
mChart.invalidate();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
private void setData(int count, float range) {
ArrayList<String> xVals = new ArrayList<String>();
for (int i = 0; i < count; i++) {
xVals.add((5 +i) + "Minutes");
}
ArrayList<Entry> vals1 = new ArrayList<Entry>();
for (int i = 0; i < count; i++) {
float mult = (range + 1);
float val = (float) (Math.random());// + (float)
// ((mult *
// 0.1) / 10);
vals1.add(new Entry(val, i));
}
// create a dataset and give it a type
LineDataSet set1 = new LineDataSet(vals1, "DataSet 1");
set1.setDrawCubic(true);
set1.setCubicIntensity(0.2f);
set1.setDrawFilled(true);
set1.setDrawCircles(false);
set1.setLineWidth(2f);
set1.setCircleSize(5f);
set1.setHighLightColor(Color.rgb(244, 117, 117));
set1.setColor(Color.rgb(52, 152, 219));
ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
dataSets.add(set1);
// create a data object with the datasets
LineData data = new LineData(xVals, dataSets);
// set data
mChart.setData(data);
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// TODO Auto-generated method stub
}
}
//import android.app.Activity;
//import android.os.Bundle;
//import android.view.Menu;
//import android.view.MenuItem;
//
//public class CloseTabScreen extends Activity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_close_tab_screen);
// }
//}